package com.masterclient.app.modules.aftersale.contract;

import com.eoner.baselib.container.CommonBaseResponse;
import com.eoner.baselib.presenter.ThrowableConsumer;
import com.eoner.baselibrary.bean.aftersale.SendLogisticInfoBean;
import com.masterclient.app.httpservice.RetrofitUtil2;

import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
* Created by TMVPHelper on 2017/08/27
*/
public class SendLogisticInfoPresenter extends SendLogisticInfoContract.Presenter{

    @Override
    public void getSendLogisticInfo(String order_id, String biz_type) {
        Observable<CommonBaseResponse<SendLogisticInfoBean>> observable = RetrofitUtil2.getInstance().getSendLogisticInfo(order_id,biz_type);
        Disposable disposable = toSubscribe(observable, (Consumer<CommonBaseResponse<SendLogisticInfoBean>>) bean -> {
            if(bean.getCode() == 0){
                mView.showSendLogisticInfo(bean.getData());
            }else {
                mView.showFail(bean.getMsg());
            }
        }, new ThrowableConsumer());
        mRxManager.add(disposable);
    }
}